The present invention relates to an apparatus and method for coding moving pictures and, more particularly, to an apparatus and method for compressively coding a video signal so as to reduce the time from when the video signal is input to a coding apparatus until video is output from a decoding apparatus.
As a technology for compressively coding a video signal and reducing delay times required for coding and decoding, a low delay coding method according to MPEG2 is described in ISO-IEC/JTC/SC29/WC11 NO328 xe2x80x9cTest Model 3xe2x80x9d.
In this low delay coding method according to MPEG 2, B pictures are not employed and therefore the delay time required for rearrangement of frames is reduced. Further, I picture is inserted only at the head and accordingly the numbers of bits in respective pictures are made equal as much as possible, thereby reducing the delay time of buffering which occurs in an input buffer of the decoding apparatus.
In addition, when an error arises, the technique of intra-slice or intra-column coding is employed to remove noises which arise on a screen. In this technique, the intra-coding is periodically performed by several slices in the frame of P picture or per column having a width of several macroblocks. When one cycle that all areas in the screen are intra-coded is completed, the noises are removed.
In the rate control method, the method which is the same as xe2x80x9cTest Model 3xe2x80x9d, a method other than the low delay is employed. In this method, the target number of bits of one picture is set and the quantization width is calculated on the basis of the difference between the target number of bits, which linearly increases in the picture, and the actual number of generated bits. When the intra-slice coding method is to be employed, the target number of bits of the picture is weighted so as to increase the rate of increase in the target number of bits in the area which is to be intra-slice coded.
However, in this rate control method, the number of generated bits in one picture can exceed the target number of bits in one picture. The numbers of generated bits in respective pictures vary. Accordingly, frame dropping in the video or the increase in the delay time of buffering in the input buffer of the decoder occurs. This is described with reference to FIGS. 18(a) and 18(b).
FIGS. 18(a) and 18(b) are diagrams for explaining states where the frame dropping or increase in the delay time occurs.
In the case where the number of generated bits after coding is increased and the difference between this number and the target number of bits exceeds the tolerance, when the coding of pictures is not skipped as shown in FIG. 18(a), a previously decided delay time is exceeded.
In addition, in order to prevent the frame dropping, it is required to increase the delay time of the buffering in the input buffer of the decoder as shown in FIG. 18(b).
Further, when the variation of the numbers of bits in the respective pictures is to be suppressed in the rate control method, the number of generated bits should be suppressed in a picture whose number of generated bits is increased, by the skip of the coding of macroblocks or by extremely increasing the quantization width. Therefore, the image quality of video after decoding is extremely deteriorated.
It is an object of the present invention to provide an apparatus and method for coding moving pictures, which reduces the delay time in the decoding apparatus as well as prevents the frame dropping of the video after decoding and stably maintains the image quality.
Other objects and advantages of the present invention will become apparent from the detailed description and specific embodiments described are provided only for illustration since various additions and modifications within the spirit and scope of tho invention will be apparent to those of skill in the art from the detailed description.
A moving picture coding apparatus according to a 1st aspect of the present invention comprises: a coding processing means for coding a video signal in a frame for each block of a prescribed area; and a rate control means for controlling the coding processing means so that a generated code amount after coding of the video signal is fixed for each code amount control unit as a unit of the frame or a unit which is smaller than the frame. Therefore, the delay time of buffering in an input buffer of a decoding apparatus can be reduced.
According to a second aspect of the present invention, in the moving picture coding apparatus of the first aspect, the rate control means comprises.: a generated code amount detection means for detecting a cumulative amount of generated codes as a cumulative value of amounts of codes generated from a first block to a block which is being coded in a code amount control unit which is being coded; and a target code amount calculation means for setting a target generated code amount per code amount control unit as a target value of accumulation of amounts of codes which are generated from a first block to a last block in the code amount control unit, and calculating a target code amount as a target value of accumulation of amounts of codes which are generated from the first block which is being coded in the code amount control unit. The rate control means also comprises: an upper limit code amount calculation means for calculating an upper limit code amount as an upper limit value of accumulation of generated code amounts per code amount control unit; and a quantization scale calculation means for calculating a quantization scale of the block which is being coded, on the basis of the cumulative generated code amount calculated by the generated code amount detection means, the target code amount calculated by the target code amount calculation means, and the upper limit code amount calculated by the upper limit code amount calculation means. Therefore, the image quality of video can be stably maintained without causing video frame dropping after decoding, and the delay time of the buffering in the input buffer of the decoding apparatus can be reduced.
According to a third aspect of the present invention, in the moving picture code apparatus of the second aspect, when the cumulative generated code amount exceeds the upper limit code amount in the code amount control unit which is being coded, the quantization scale calculation means generates an underflow avoidance signal for skipping coding of a block in the code amount control unit by the coding processing means until the cumulative generated code amount becomes equal to or less than the upper limit code amount, thereby avoiding underflow, and when the cumulative generated code amount of the code amount control unit which has been coded does not reach the target generated code amount per the code amount control unit, the quantization scale calculation means subtracts the cumulative generated code amount from the target generated code amount per code amount control unit, thereby calculating a stuffing code amount for a stuffing processing by the coding processing means. Therefore, the number of generated bits in the code amount control unit such as one picture can be fixed.
According to a fourth aspect of the present invention, in the moving picture coding apparatus of the second aspect, the quantization scale calculation means obtains a tolerance generated code amount as a difference between the upper limit code amount and the target code amount as well as obtains a generated code amount error as a difference between the cumulative generated code amount and the target code amount, and calculates the quantization scale using a quantization scale decision function having inclinations which vary with values of the generated code amount error with respect to the tolerance generated code amount. Therefore, the changes in the quantization scale in a frame can be reduced, whereby inconsistencies of the image quality in the frame can be reduced.
According to a fifth aspect of the present invention, in the moving picture coding apparatus of the fourth aspect, the quantization scale decision function has a smaller inclination in the vicinity of 0 of the generated code amount error with respect to the tolerance generated code amount, than in a part where the value of the generated code amount error with respect to the tolerance generated code amount is larger. Therefore, the changes in the quantization scale in a frame can be reduced, whereby the inconsistencies of the image quality in the frame can be reduced.
According to a sixth aspect of the present invention, in the moving picture coding apparatus of the second aspect, the target code amount calculation means obtains distribution of degree of coding difficulty in each code amount control unit when the coding of the code amount control unit has been finished, and calculates the target code amount of a block which is being coded in a subsequent code amount control unit on the basis of the obtained distribution of degree of coding difficulty. Therefore, even when the distribution of the degree of coding difficulty is uneven in a frame, the image quality of video after decoding can be further uniformed in the frame.
According to a seventh aspect of the present invention, in the moving picture coding apparatus of the fourth or sixth aspect, the quantization scale decision function has a reference quantization as a parameter, and the quantization scale calculation means changes the reference quantization scale for each code amount control unit on the basis of the degree of coding difficulty of each code amount control unit. Therefore, the coding can be performed with the quantization scale having a smaller value for video having a lower degree of coding difficulty, whereby the image quality of the video after decoding can be improved.
According to an eighth aspect of the present invention, in the moving picture coding apparatus of the fourth or sixth aspect, the quantization scale decision function has a reference quantization scale as a parameter, and the quantization scale calculation means changes the reference quantization scale for each code amount control unit on the basis of a quantization scale of each of the code amount control units which have been already coded. Therefore, the coding can be performed with the quantization scale having a smaller value for video having a lower degree of coding difficulty, whereby the image quality of the video after decoding can be improved.
According to a ninth aspect of the present invention, in the moving picture coding apparatus of the fourth aspect, the quantization scale decision function is made so that the quantization scale varies according to changes in the value of the generated code amount error with respect to the tolerance generated code amount with possessing hysteresis characteristics. Therefore, even when the degree of coding difficulty in a frame is greatly increased or decreased, the changes in the quantization scale can be suppressed. Accordingly, the larger changes in the image quality after decoding in the frame can be suppressed.
According to a tenth aspect of the present invention, the moving picture coding apparatus of the first aspect comprises: a code amount control unit changing means for changing the code amount control unit according to a delay time required for decoding of coded data by a decoding apparatus which decodes the coded data output by the moving picture coding apparatus. Therefore, the delay time of the buffering in the input buffer of the decoding apparatus can be further reduced.
According to an eleventh aspect of the present invention, in the moving picture coding apparatus of the second aspect, the upper limit code amount calculation means changes the upper limit code amount according to a delay time required for decoding of coded data by a decoding apparatus which decodes the coded data output by the moving picture coding apparatus. Therefore, the image quality of the decoding can be improved.
According to a twelfth aspect of the present invention, the moving picture coding apparatus of any of the first to eleventh aspects comprises: a receiving means for receiving an address of a position of an error which arises in a frame; and an intra area transition means for successively transitioning a position of an area to be intra-coded in each predictive coding frames arranged in the video signal in the order of arrangement of the predictive coding frames in the video signal, and when an error arises in coded data in the video signal, transitioning a position of an area to be intra-coded of a subsequent predictive coding frame to a position of the error in the predictive coding frame on the basis of the address from the receiving means. Therefore, when an error arises in a coded bitstream and noises occur in the video after decoding, the time taken to remove the noises can be reduced.
A moving picture coding method according to a thirteenth aspect of the present invention for coding a video signal for each block of a prescribed area in a frame and controlling an amount of generated codes in a unit for the frame or a unit which is smaller than the frame. The moving picture coding method comprises: detecting a cumulative amount of generated codes as a cumulative value of amounts of codes generated from a first block to a block which is being coded in a code amount control unit which is being coded; calculating a target generated code amount per code amount control unit as a target value of an amount of generated codes per code amount control units; and calculating a target code amount as a target value of accumulation of amounts of codes generated from the first block to the block which is being coded in the code amount control unit on the basis of the target generated code amount per code amount control unit. The motion picture coding method also comprises: calculating an upper limit code amount as an upper limit value of accumulation of amounts generated codes per code amount control unit on the basis of the target generated code amount per code amount control unit; calculating a tolerance generated code amount as a difference; between the upper limit code amount and the target code amount; calculating a generated code amount error as a difference between the cumulative generated code amount and the target code amount; and obtaining a value of the generated code amount error with respect to the tolerance generated code amount, and calculating a quantization scale of a block which is being coded using a quantization scale decision function whose inclination is changed according to the value of the generated code amount error with respect to the tolerance generated code amount. Therefore, the image quality of video can be stably maintained without causing frame dropping of the video after decoding and the delay time of buffering in the input buffer of the decoding apparatus can be reduced.
According to a fourteenth aspect of the present invention, the moving picture coding method of the thirteenth aspect comprises: when the cumulative amount of generated codes exceeds the upper limit code amount in a code amount control unit which is being coded, skipping coding of a block in the coding control unit until the cumulative amount of generated codes becomes equal to or smaller than the upper limit code amount; and when the cumulative amount of generated codes of the coding control unit which has been coded does not reach the target generated code amount per code amount control unit, performing stuffing so that the cumulative amount of generated codes reaches the target generated code amount per code amount control unit. Therefore, the number of generated bits of the coding control unit such as one picture can be fixed.